package org.aceor.mddal.common.utils;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by lxue on 16/4/11.
 */
public class ExceptionUtil {

    public static void throwAllSQLExceptions(List<SQLException> exceptions) throws SQLException {
        SQLException exception = new SQLException();
        List<StackTraceElement> stackTraceElements = new LinkedList<StackTraceElement>();
        for (SQLException sqlException : exceptions) {
            stackTraceElements.addAll(Arrays.asList(sqlException.getStackTrace()));
        }
        exception.setStackTrace(stackTraceElements.toArray(new StackTraceElement[stackTraceElements.size()]));
        throw exception;
    }

}
